import Mock from 'mockjs'

Mock.mock('/api/login', 'post', (options) => {
    const { username, password } = JSON.parse(options.body)
    if (username === 'admin' && password === '123456') {
        return Mock.mock({
            code: 200,
            message: '登录成功',
            data: {
                token: Mock.Random.guid(),
                userInfo: {
                    id: 1,
                    username: 'admin',
                    name: '管理员',
                    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
                }
            }
        })
    } else {
        return Mock.mock({
            code: 401,
            message: '用户名或密码错误'
        })
    }
})